




<%@ page contentType="text/html;charset=UTF-8" %>

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${Inter.printOut('Application',session.language)}</title>
    <link rel="stylesheet" href="${resource(dir:'css',file:'main.css')}" />
    <g:javascript src="jquery.js" />
    <g:javascript library="application" />
  </head>
  <body>
    <%  def picture = "merp_logo_small.png" %>
    <div class="logo">
          <a href="${link}" target="_blank" ><img src="${resource(dir:'images',file:picture)}" style="float:left; margin-left:10px;" alt="IDA" border="0" /></a>
           <!--the language button with flag and so on-->
           <div style="float:right">
            <g:btnLanguage language="${session.language}"  currentController="employee" currentView="applicationApplicant" scheduleId="${params.scheduleId}" courseId="${params.courseId}" employeeId="${fieldValue(bean:employeeInstance, field:'employeeId').replaceAll(',','')}" ></g:btnLanguage>
           </div>
          </div>
    <hr>
      <div class="body">
        <g:javascript src="jquery.livequery.js" />
        <g:javascript src="budget/editFigures.js" />
    <h1>${Inter.printOut('Application',session.language)}</h1>
   <!-- <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>-->

     <g:hasErrors bean="${employeeInstance}">
            <div class="errors">
                <g:renderErrors bean="${employeeInstance}" as="list" />  </div>
     </g:hasErrors>

     <!--hmmm-->


    <!--Id= persoin nummer-->

            <h2 style="margin-left:5px;">${Inter.printOut('Civic number',session.language)}: ${fieldValue(bean:employeeInstance, field:'employeeId').replaceAll(',','')} </h2>
              <!--info has already-->



     <!--choose course -->

                 <form id="form1" action="sendCourse" method="post">
<%
def courseList = Course.listOfCoursesNotEmpty("CUL")
%>
                    <label for="course">${Inter.printOut('Course',session.language)}:</label>

                    <g:if test="${courseList.size()>0}">
                          <g:if test=" ${params.courseId && !params.courseId.equals('null')}">
                              <g:select id="selectCourseId" optionKey="id" from="${courseList}" name="courseId" value="${params.courseId}" ></g:select>
                          </g:if>
                          <g:else>
                              <g:select noSelection="['null':'Choose a course']" id="selectCourseId" optionKey="id" from="${courseList}" name="courseId" value="${params.courseId}" ></g:select>
                          </g:else>
                    </g:if>
                    <g:else>
                      <div class="message">${Inter.printOut('No courses are available',session.language)}</div>
                    </g:else>

                    <input  type="hidden" id="employeeId" name="employeeId" value="${employeeInstance.employeeId}">
                    <input  type="hidden" id="applicationId" name="applicationId" value="applicationApplicant">
                </form>

<!--display info and then save some changes employee: ok null parts-->



                  <!--choose schedule-->
<g:if test="${params.courseId && !params.courseId.equals('null')}">

    <form id="form2" action="sendSchedule" method="post">


        <%
            def scheduleList = Schedule.listNotApplied(employeeInstance.id,params.courseId)
        %>
        <g:if test="${scheduleList.size()>0}">
          <label for="time">${Inter.printOut('Time',session.language)}:</label>
            <g:if test=" ${params.scheduleId && !params.scheduleId.equals('null')}">
                <g:select id="selectScheduleId" optionKey="id" from="${scheduleList}" name="scheduleId" value="${params.scheduleId}" ></g:select>
            </g:if>
            <g:else>
                <g:select noSelection="['null':'Choose a time']" id="selectScheduleId" optionKey="id" from="${scheduleList}" name="scheduleId" value="${params.scheduleId}" ></g:select>
            </g:else>
      </g:if>
      <g:else>
          <div class="message">${Inter.printOut('You have already applied for all schedules in this course!',session.language)}</div>
      </g:else>
      <input  type="hidden" id="employeeId" name="employeeId" value="${employeeInstance.employeeId}">
      <input  type="hidden" id="applicationId" name="applicationId" value="applicationApplicant">
      <input  type="hidden" id="courseId" name="courseId" value="${params.courseId}">
    </form>

    <g:if test=" ${params.scheduleId && !params.scheduleId.equals('null')}">
        <g:form action="applicationApplicant" method="post" >
          <div class="dialog">
            <table style="border:none;table-layout: fixed">
              <tbody>
           
                 <!--namn-->
                            <tr class="prop">
                                <td valign="top" class="name">
                                  <label for="firstName">
                                    ${Inter.printOut('First Name:',session.language)}
                                  </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'firstName','errors')}">
                                     <g:if test="${employeeInstance.firstName.equals('non')}">
                                    <input type="text" maxlength="20" id="firstName" name="firstName" value="${}"/>
                                    </g:if>
                                    <g:else>
                                    <input type="text" maxlength="20" id="firstName" name="firstName" value="${fieldValue(bean:employeeInstance,field:'firstName')}"/>
                                    </g:else>
                                     </td>
                            </tr>

                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="lastName">
                                      ${Inter.printOut('Last Name:',session.language)}
                                    </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'lastName','errors')}">
                                  <g:if test="${employeeInstance.lastName.equals('non')}">
                                    <input type="text" maxlength="20" id="lastName" name="lastName" value="${}"/>
                                  </g:if>
                            <g:else>
                                    <input type="text" maxlength="20" id="lastName" name="lastName" value="${fieldValue(bean:employeeInstance,field:'lastName')}"/>
                            </g:else>
                            </td>
                            </tr>

                            <!--email-->
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="email">
                                      ${Inter.printOut('Email:',session.language)}
                                    </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(employeeInstance.email,'errors')}">
                                   <g:if test="${employeeInstance.email.equals('non@non.non')}">
                                     <input type="text" maxlength="50" id="email" name="email"/>
                                   </g:if>
                                  <g:else>
                                          <input type="text" maxlength="50" id="email" name="email" value="${employeeInstance.email}"/>
                                  </g:else>
                            </td>
                            </tr>

                            <!--title-->
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="title">${Inter.printOut('Title:',session.language)} </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'title','errors')}">
                                  <g:if test="${employeeInstance.title.equals('non')}">
                                    <input type="text" maxlength="20" id="title" name="title" title="${Inter.printOut('employee_title_hover',session.language)}" value="${}"/>
                                  </g:if>
                            <g:else>
                                    <input type="text" maxlength="20" id="title" name="title" title="${Inter.printOut('employee_title_hover',session.language)}" value="${fieldValue(bean:employeeInstance,field:'title')}"/>
                            </g:else>
                                  </td>
                            </tr>


                                      <!--lukasid not exists only if employee not for external-->
                                <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="lukasId">
                                     Lukasid:
                                    </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:participationsInstance,field:'lukasId','errors')}">
                                    <input type="text" maxlength="20" id="lukasId" name="lukasId" value="${params.lukasId}"/>
                                </td>
                            </tr>



                           <!-- department institution-->
                                <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="department">Institution: </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:participationsInstance,field:'department','errors')}">
                                    <input type="text" maxlength="20" id="department" name="department" value="${params.department}"/>
                                </td>
                            </tr>

                            <!--division avdelning-->
                             <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="division">${Inter.printOut('Department',session.language)}: </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:participationsInstance,field:'division','errors')}">
                                    <input type="text" maxlength="20" id="division" name="division" value="${params.division}"/>
                                </td>
                            </tr>
                            <!--faculty exists -->
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="faculty">${Inter.printOut('Faculty',session.language)}: </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:employeeInstance,field:'faculty','errors')}">
                                    <input type="text" maxlength="20" id="faculty" name="faculty" value="${params.faculty}"/>
                                </td>
                            </tr>

                             <!--fakturaadress square not eexist not in employee  take for description for project  billingAdress-->
                                   <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="billingAdress">${Inter.printOut('Billing address',session.language)}:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:projectInstance,field:'billingAdress','errors')}">
                                    <textarea rows="5" cols="40" name="billingAdress">${params.billingAdress}</textarea>
                                </td>
                            </tr>

                              <!--Kundnr/motpartskonto (internt liu) not exists-->
                             <tr class="prop">
                                <td valign="top" class="name">
                                <label for="bankAccount">${Inter.printOut('Recipient account number',session.language)}: </label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:participationsInstance,field:'bankAccount','errors')}">
                                     <input type="text" maxlength="20" id="bankAccount" name="bankAccount" value="${params.bankAccount}"/>
                                </td>
                            </tr>
                              <!--Jag har talat med ekonomiskt ansvarig som accepterat att betala kurskostnaden : square-->

                         <!--<tr>
                             <td><input type="checkbox" name="fields_10_" value="true"></td>
                           <td>Jag har talat med ekonomiskt ansvarig som accepterat att betala kurskostnaden</td>

                           </tr>-->
                        


                  </tbody>
            </table>
                   <input  type="hidden" id="courseId" name="courseId" value="${params.courseId}">
                   <input  type="hidden" id="scheduleId" name="scheduleId" value="${params.scheduleId}">
                    <input  type="hidden" id="applicationId" name="applicationId" value="applicationApplicant">
                    <input  type="hidden" id="employeeId" name="employeeId" value="${employeeInstance.employeeId}">
                    <input  type="hidden" id="checkErrorId" name="checkErrorId" value="checkErrorId">
            </div>
            <div class="buttons">
                <span class="button"><input class="save" type="submit" value="Apply" /></span> <!--if new employee else annat-->
            </div>

        </g:form>
      </g:if>
</g:if>

      </div>
  </body>
</html>

